<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <script src="__STATIC__/js/jquery.js"></script>
    <script src="__STATIC__/layui/layui.js"></script>
    <script src="__STATIC__/bootstrap-table/js/bootstrap-table.js"></script>
    <script src="__STATIC__/bootstrap-table/js/bootstrap-table-zh-CN.min.js"></script>
    <script src="__STATIC__/bootstrap-table/js/dropdown.js"></script>
    <link rel="stylesheet" href="__STATIC__/bootstrap-table/css/bootstrap-table.min.css">
    <link rel="stylesheet" href="__STATIC__/bootstrap-table/css/bootstrap.css">
    <script type="text/javascript" src="__STATIC__/x-admin/js/xadmin.js"></script>
    <link rel="stylesheet" href="__STATIC__/x-admin/css/font.css">
    <link rel="stylesheet" href="__STATIC__/x-admin/css/xadmin.css">
</head>
<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="#">数据管理</a>
        <a href="#">教学数据</a>
        <a href="#">排课信息</a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="layui-row">
    <form class="layui-form layui-col-md12 x-so" onsubmit="return false">
        <input type="text" name="schoolName"  placeholder="学校名称" autocomplete="off" class="layui-input">
        <input type="text" name="teacherName"  placeholder="教师名称" autocomplete="off" class="layui-input">
        <input type="text" name="courseName"  placeholder="课程名" autocomplete="off" class="layui-input">
        <input type="text" name="year" id="year" placeholder="学年" autocomplete="off" class="layui-input">
        <button class="layui-btn" id="search"><i class="layui-icon">&#xe615;</i></button>
    </form>
</div>
<table id="course">

</table>
</body>
<script>
    layui.use('laydate',function(){
        var laydate = layui.laydate;
        laydate.render({
            elem: '#year'
            ,type: 'year'
        });
    });
</script>
<script>
    $('#course').bootstrapTable({
        //获取行号
        language: 'zh-CN',
        todayHighlight: true,
        striped: true,//设置为 true 会有隔行变色效果
        method: 'post',//服务器数据的请求方式 'get' or 'post'
        url: "{:url('/course/getCourseInfo')}",//服务器数据的加载地址
        toolbar:'#toolbar',//
        searchOnEnterKey:true,
        sortName:'ID',//排序字段
        sortOrder : 'desc',//降序
        sidePagination: "server",   //分页方式：client客户端分页，server服务端分页（*）
        pagination: 'false',//设置为 true 会在表格底部显示分页条
        clickToSelect:'true',//设置true 将在点击行时，自动选择rediobox 和 checkbox
        singleSelect:'true',//设置True 将禁止多选
        pageSize: '30',//如果设置了分页，页面数据条数
        pageList:[30,60,90,100],
        smartDisplay:false,
        //得到查询的参数
        queryParams : function (params) {
            //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
            var temp = {
                rows: params.limit,                         //页面大小
                page: (params.offset / params.limit) + 1,   //页码
                sort: params.sort,      //排序列名
                sortOrder: params.order,//排位命令（desc，asc）
                schoolName:$("input[name=schoolName]").val(),
                teacherName:$("input[name=teacherName]").val(),
                courseName:$("input[name=courseName]").val(),
                year:$("input[name=year]").val(),
                start:$("#start").val(),
                end:$("#end").val()
            };
            return temp;
        },
        columns: [
//                {title:'请选择',align:'center',checkbox : true},
            {field: 'id', title: 'ID', align:'center'},
            {title: '学校名称', align:'center',formatter:school},
            {title: '教师名称', align:'center',formatter:teacher},
            {field: 'monday', title: '星期一', align:'center'},
            {field: 'tuesday', title: '星期二', align:'center'},
            {field: 'wednesday', title: '星期三', align:'center'},
            {field: 'thursday', title: '星期四', align:'center'},
            {field: 'friday', title: '星期五', align:'center'},
            {field: 'mark', title: '第几节课', align:'center'},
            {field: 'year', title: '学年', align:'center'},
            {field: 'create_time',title: '测试时间', align:'center'},
            {title: '操作', align:'center',formatter:operation}
        ]
    });
    //学校信息
    function school(val,rows){
        if(rows.get_teacher_info.school){
            return rows.get_teacher_info.school.school_name;
        }
    }
    //教师信息
    function teacher(val,rows){
        if(rows.get_teacher_info){
            return rows.get_teacher_info.teacher_name;
        }
    }
    //操作按钮
    function operation(val,rows){
        return [
            "<button type='button' class='btn btn-primary btn-xs' onclick='record("+rows.get_teacher_info.id+")'>上课记录</button>&nbsp;&nbsp;",
            "<button type='button' class='btn btn-info btn-xs' onclick='lessonPreparation("+rows.get_teacher_info.id+','+rows.id+")'>备课信息</button>"
        ].join('')
    }
    //检索
    $("#search").click(function(){
        $('#course').bootstrapTable(('refresh'));
    });
    //上课记录
    function record(teacherId){
        window.location.href = "{:url('/course/classRecord')}?teacher_id="+teacherId;
    }
</script>
</html>